package org.o14x.alpha.ui.perspectives;

import java.io.File;

import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
import org.o14x.alpha.ui.controller.UIController;
import org.o14x.alpha.ui.views.folder.FolderView;
import org.o14x.alpha.ui.views.foldertree.FolderTreeView;

/**
 * Main perspective.
 * 
 * @author Olivier DANGREAUX
 */
public class MainPerspective implements IPerspectiveFactory {
	/**
	 * ID
	 */
	public final static String ID = MainPerspective.class.getName();

	/**
	 * The UIController.
	 */
	private UIController uiController;

	/**
	 * {@inheritDoc}
	 */
	public void createInitialLayout(IPageLayout layout) {
		uiController.getDomain().setCurrentExplorerTab(uiController.getDomain().getExplorerTabManager().getNewExplorerTab());
		uiController.getDomain().getCurrentExplorerTab().navigate(File.listRoots()[0]);

		String editorArea = layout.getEditorArea();
		layout.setFixed(false);
		layout.setEditorAreaVisible(false);

		layout.addStandaloneView(FolderTreeView.ID, true, IPageLayout.LEFT, 0.4f, editorArea);
		IFolderLayout folder = layout.createFolder("folderViews", IPageLayout.TOP, 0.5f, editorArea);
		folder.addPlaceholder(FolderView.ID + ":*");
		folder.addView(FolderView.ID);
		//layout.addStandaloneView(FolderView.ID, true, IPageLayout.TOP, 0.5f, editorArea);
		//layout.addStandaloneViewPlaceholder(FolderView.ID, IPageLayout.TOP, 0.5f, editorArea, true);

		layout.getViewLayout(FolderTreeView.ID).setCloseable(false);
	}

	/**
	 * Returns the value of uiController.
	 *
	 * @return The value of uiController.
	 */
	public UIController getUiController() {
		return uiController;
	}

	/**
	 * Sets the value of uiController.
	 *
	 * @param uiController The value of uiController to set.
	 */
	public void setUiController(UIController uiController) {
		this.uiController = uiController;
	}
}
